import axios from 'axios'
//登录
//验证账号密码
export const loginAdmin = async ({adminName,adminPassword}) => {
    // console.log({adminName,adminPassword},"get1")
    let res = await axios({
         method:"post",
         url:"/api/admins/login",
         data:{
            adminName,
            adminPassword
        } 
    })
    return res.data
}

//注册
//验证注册是否有重复
export const isAdmin = async ({adminName,adminPassword,phone,Email,name,role,state}) => {
    let res = await axios({
         method:"post",
         url:"/api/admins/login", 
         data:{
            adminName,
            adminPassword,
            phone,
            Email,
            name,
            role,
            state
        }
    })
    return res.data
}
//列表
//获取数据
export const getAdmin = async () => {
    let res = await axios({
         method:"get",
         url:"/api/admins/", 

    })
    return res.data
}
//添加数据
export const addAdmin = async ({adminName,adminPassword,phone,Email,name,role,state}) => {
    let res = await axios({
         method:"post",
         url:"/api/admins/create",
         data:{
            adminName,
            adminPassword,
            phone,
            Email,
            name,
            role,
            state
        } 
    })
    return res.data
}
//删除数据
export const  deleAdmin = async (_id) => {
    let res = await axios({
         method:"post",
         url:"/api/admins/dele",  
         data: { _id }
    })   
    return res.data
}
//更新数据
export const UpdateAdmin = async (_id,{adminName,adminPassword,phone,Email,name,role,state}) => {
    let res = await axios({
         method:"patch",
         url:"/api/admins/",  
         data:{
            _id,
            adminName,
            adminPassword,
            phone,
            Email,
            name,
            role,
            state
        } 
    }); 
    return res.data
} 
//搜索数据
export const searchAdmin = async (data) => {
    console.log(data,"axios")
    let res = await axios({
         method:"post",
         url:"/api/admins/search", 
         data:data,
    })
    console.log(res.data)
    return res.data
}
